package server;

    public abstract class MyHttpServlet implements MyServlet{

    /**
     *
     *功能描述:get请求处理方法
     * @param  request
     * @param  response
     * @return void
     * @author zj
     * @date 2021/7/17
     */
    public abstract  void doGet(Request request, Response response);

    /**
     *
     *功能描述:post请求处理方法
     * @param  request
     * @param  response
     * @return void
     * @author zj
     * @date 2021/7/17
     */
    public abstract  void doPost(Request request, Response response);

    @Override
    public void service(Request request, Response response) throws Exception {
        //判断是get请求还是post请求
        String method = request.getMethod();
        if("GET".equalsIgnoreCase(method)){
            doGet(request,response);
        }else {
            doPost(request,response);
        }
    }
}
